<fieldset>
<div class="suppliers view">
<div id="view">
     <h2><?php echo __('Supplier'); ?></h2>
     <br />
  
<table class="inlineTable" width="40%" cellpadding='0' cellspacing='1'>
    <tr>
		<td class="heading" width="30%"><?php echo __('Supplier Name'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['supplierName']); ?>&nbsp;</td>
    </tr>
    <tr>
		<td class="heading" width="30%"><?php echo __('Contact Person'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['contactPersonName']); ?>&nbsp;</td>
    </tr>
    <tr>
		<td class="heading" width="30%"><?php echo __('Comment'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['comment']); ?>&nbsp;</td>
    </tr>
</table>
<table class="inlineTable" width="25%" cellpadding='0' cellspacing='1'> 
    <tr>
		<td class="heading" width="30%"><?php echo __('Phone'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['phone1']); ?>&nbsp;</td>
	</tr>
	<tr>
		<td class="heading" width="30%"><?php echo __('Mobile'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['phone2']); ?>&nbsp;</td>
	</tr>
	<tr>
		<td class="heading" width="30%"><?php echo __('Email'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['email']); ?>&nbsp;</td>
	</tr>
</table>
<table class="inlineTable" width="30%" cellpadding='0' cellspacing='1'> 
    <tr>
		<td class="heading" width="30%"><?php echo __('Street'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['street']); ?>&nbsp;</td>
    </tr>
    <tr>
		<td class="heading" width="30%"><?php echo __('Suburb'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['suburb']); ?>&nbsp;</td>
    </tr>
    <tr>
		<td class="heading" width="30%"><?php echo __('State'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['state']); ?>&nbsp;</td>
    </tr>
    <tr>
		<td class="heading" width="30%"><?php echo __('Post Code'); ?></td>
		<td class="data" width="70%"><?php echo h($supplier['Supplier']['pc']); ?>&nbsp;</td>
    </tr>
</table>
<br /><br />
              
</div>
</div>
<div class="newbutton">
	<ul>
		<li><?php echo $this->Html->link(__('Edit Details'), array('action' => 'edit', $supplier['Supplier']['id'])); ?></li>
		<li><?php echo $this->Form->postLink(__('Archive'), array('action' => 'delete', $supplier['Supplier']['id']), null, __('Are you sure you want to archive supplier, %s ?', $supplier['Supplier']['supplierName'])); ?></li>
		<li><?php echo $this->Html->link(__('Back'), array('action' => 'index')); ?></li>
	</ul>
</div>
<br><br><br>

<!doctype html>
 
<script src ="app/webroot/js/bootstrap/bootstrap.js"></script>
<script>
    $('#myTab a').click(function (e) {
  		e.preventDefault()
  		$(this).tab('show')
  
})
</script>

<ul class="nav nav-tabs" id="myTab">
	<li class="active"><a href="#tab-1" data-toggle="tab">Products</a></li>
  	<li><a href="#tab-2" data-toggle="tab">Orders</a></li>
</ul>
    
     
<div class="tab-content">
	<div class="tab-pane active" id="tab-1">
<?php if (!empty($supplier['Product'])){?> 
		<table class="table" cellpadding = "0" cellspacing = "0" width="60%"> 
			<tr> 
				<th>Products</th> 
				<th>Size</th> 
				<th><?php echo __('Actions');?></th> 
			</tr>
<?php foreach ($supplier['Product'] as $product): ?> 
			<tr> 
				<td><?php echo $product['description'];?></td> 
				<td><?php echo $product['size'];?></td> 
				<td class="actions"> 
<?php echo $this->Html->link(__('View'), array('controller' => 'Products', 'action' => 'view', $product['id'])); ?> 
<?php echo $this->Html->link(__('Edit'), array('controller' => 'Products', 'action' => 'edit', $product['id'])); ?> 
				</td> 
			</tr> 
<?php endforeach; ?> 
		</table> 
<?php } else { echo 'No products under this supplier.';} ?> 
	</div> 
   
 	<div class="tab-pane" id="tab-2">
<?php if (!empty($supplier['Order'])){?> 
		<table class="table" cellpadding = "0" cellspacing = "0" width="60%"> 
			<tr> 
				<th>Date created </th> 
				<th>Status</th> 
				<th><?php echo __('Actions');?></th> 
			</tr>
<?php foreach ($supplier['Order'] as $order): ?> 
			<tr> 
				<td><?php echo $order['created'];?></td> 
				<td>
					<?php 	if($order['Order']['status'] == '0'){
								echo 'Not Completed';
							}
							else if($order['Order']['status'] == '2'){
								echo 'Partially Completed';
							}
							else{
								echo 'Completed';
							}?>
				</td> 
				<td class="actions"> 
<?php echo $this->Html->link(__('View'), array('controller' => 'Orders', 'action' => 'view', $order['id'])); ?> 
<?php echo $this->Html->link(__('Generate PDF'), array('controller' => 'orders','action' => 'viewPdf', $order['id'])); ?>
				</td> 
			</tr> 
<?php endforeach; ?> 
		</table> 
<?php } else { echo 'No orders under this supplier.';} ?> 
	</div> 
</div>	
</fieldset>